<%--
  Created by IntelliJ IDEA.
  User: WJ
  Date: 2020/7/29
  Time: 9:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<html>
<head>
    <title>Title</title>
    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        用户名：${sessionScope.username}
        <table class="table table-hover">
            <tr>
                <td>id</td>
                <td>name</td>
                <td>phone</td>
                <td>email</td>
                <td>title</td>
                <td>content</td>
                <td>createdtime</td>
                <td>操作</td>
                <td><a href="./AddMessage.jsp" class="btn btn-info">添加</a></td>
            </tr>
            <c:forEach var="gb" items="${sessionScope.list}" varStatus="status">
                <tr>
                    <td>${status.index+1}</td>
                    <td>${gb.name}</td>
                    <td>${gb.phone}</td>
                    <td>${gb.email}</td>
                    <td>${gb.title}</td>
                    <td>${gb.content}</td>
                    <td>${gb.createdtime}</td>
                    <td>
                        <a href="<%=request.getContextPath()%>/upd?id=${gb.id}&q=edit" class="btn btn-primary">修改</a>
                        <a href="#" class="btn btn-danger" onclick="deletebyid(${gb.id})">删除</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
    </div>


    <script>
        function deletebyid(id) {
            let q=confirm("确定要删除该信息吗？")
            if (q){
                window.location.href="${pageContext.request.contextPath}/user/manager?q=delete&id="+id;
            }
        }
    </script>
</body>
</html>
